package au.edu.swin.videoshop.persistence;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name="TITLE_MEDIUM")
public class TitleMediumEntity implements Serializable{
	private Long mTitleMediumId;
	private TitleEntity mTitle;
	private String mMediumType;
	private BigDecimal mRentalRate;
	private int mMaxRentalPeriod;
	private BigDecimal mPenaltyRate;
	private List mCopies;
	
	public TitleMediumEntity(){
		mCopies = new ArrayList();
	}
	
	/**
	 * @return the titleMediumId
	 */
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	@Column(name="TITLE_MEDIUM_ID")
	public Long getTitleMediumId() {
		return mTitleMediumId;
	}
	
	/**
	 * @param titleMediumId the titleMediumId to set
	 */
	public void setTitleMediumId(Long titleMediumId) {
		mTitleMediumId = titleMediumId;
	}
	
	/**
	 * @return the title
	 */
	@ManyToOne(optional=false, fetch=FetchType.EAGER)
	@JoinColumn(name="TITLE_ID")
	public TitleEntity getTitle() {
		return mTitle;
	}
	
	/**
	 * @param title the title to set
	 */
	public void setTitle(TitleEntity title) {
		mTitle = title;
	}
	
	/**
	 * @return the mediumType
	 */
	@Column(name="MEDIUM_TYPE")
	public String getMediumType() {
		return mMediumType;
	}
	
	/**
	 * @param mediumType the mediumType to set
	 */
	public void setMediumType(String mediumType) {
		mMediumType = mediumType;
	}
	
	/**
	 * @return the rentalRate
	 */
	@Column(name="RENTAL_RATE")
	public BigDecimal getRentalRate() {
		return mRentalRate;
	}
	
	/**
	 * @param rentalRate the rentalRate to set
	 */
	public void setRentalRate(BigDecimal rentalRate) {
		mRentalRate = rentalRate;
	}
	
	/**
	 * @return the maxRentalPeriod
	 */
	@Column(name="MAX_RENTAL_PERIOD")
	public int getMaxRentalPeriod() {
		return mMaxRentalPeriod;
	}
	
	/**
	 * @param maxRentalPeriod the maxRentalPeriod to set
	 */
	public void setMaxRentalPeriod(int maxRentalPeriod) {
		mMaxRentalPeriod = maxRentalPeriod;
	}
	
	/**
	 * @return the penaltyRate
	 */
	@Column(name="PENALTY_RATE")
	public BigDecimal getPenaltyRate() {
		return mPenaltyRate;
	}
	
	/**
	 * @param penaltyRate the penaltyRate to set
	 */
	public void setPenaltyRate(BigDecimal penaltyRate) {
		mPenaltyRate = penaltyRate;
	}
	
	/**
	 * @return the copies
	 */
	@OneToMany(mappedBy="medium", cascade=CascadeType.ALL, targetEntity=TitleCopyEntity.class, fetch=FetchType.EAGER)
	public List getCopies() {
		return mCopies;
	}
	
	/**
	 * @param copies the copies to set
	 */
	public void setCopies(List copies) {
		mCopies = copies;
	}
}
